


###########################################################################

  Table 4. Comparison of Test Statistics and Model Fit in Example 1

#########################################################################



##################################################

Huddy & Khatib (2007) Original Model Fit

#################################################



library(foreign)
library(lavaan)
library(boot)

mw03<-read.dta("/Users/bv533/Dropbox/LM-Test/new empirical example/stony_brook/mw03_survey2.dta")



model<-"ni=~q22 + q20 + q23 + q24 
        sp=~q28 + q26 
        up=~q22 + q40 + q27 + q39 + q37 + q38 
"

newdata2 <- lapply(mw03,as.numeric)
newdata2<-data.frame(newdata2)
newdata2

f01<-cfa(model, data=newdata2, ordered=c("q22", "q20", "q23", "q24", "q28", "q26", 
                                         "q22", "q40", "q27", "q38", "q39", "q37"))
f01


fitMeasures(f01, c("chisq", "df", "pvalue", "nfi", "tli", "cfi", "rmsea"))





################################

    Improved LM Model Fit 

################################

newdata2 <- lapply(mw03,as.numeric)
newdata2<-data.frame(newdata2)
newdata2


new_model<-"ni=~q22 + q20 + q23 + q24 + q27
        sp=~q28 + q26
        up=~q22 + q40 + q27 + q39 + q37 + q38


"


f03 <- cfa(model = new_model, data = newdata2, ordered=c("q22", "q20", "q23", "q24", "q28", "q26", 
                                                         "q40", "q27", "q38", "q39", "q37"))
f03
fitMeasures(f03, c("chisq", "df", "pvalue", "nfi", "tli", "cfi", "rmsea"))




##########. The End

########## All results match the manuscript, 12/6/24

